package org.csu.jpetstore_cms.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.csu.jpetstore_cms.pojo.Account;
import org.csu.jpetstore_cms.pojo.Item;

import java.util.List;

@Mapper
public interface ItemMapper {
    @Select("select * from item where itemid = #{itemid}")
    List<Item> getItem(String itemid);
    @Select("select * from item")
    List<Item> getAllItem();
    @Select("select * from item where productid = #{productid}")
    List<Item> getItemByProductId(String productid);
    @Delete("delete from item where itemid = #{itemid}")
    void DeleteByItemid(String itemid);
    @Insert("insert into item(itemid,productid,listprice,unitcost,supplier,status,attr1) values " +
            "(#{itemid},#{productid},#{listprice},#{unitcost},#{supplier},#{status},#{attr1})")
    void CreatItem(Item item);

    void UpdateItem(Item item);
    @Select("SELECT * FROM item LIMIT #{pageNum}, #{pageSize}")
    List<Item> findByPage(Integer pageNum, Integer pageSize);

    @Select("SELECT COUNT(*) FROM item")
    int getCount();
}
